<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <title>编辑我的信息</title>
    <script type="text/javascript">
      Ext.onReady(function(){
              var auditorId = <%= session[:auditor_id] %>
              var departmentDS = new Ext.data.Store({
                proxy:new Ext.data.HttpProxy({url:'/department/getDepartments'}),
                autoLoad:true,
                reader:new Ext.data.JsonReader({
                }, [
                  {name:'name'},
                  {name:'id'}
                ])
              });
              var editAuditorForm=new Ext.form.FormPanel({
                    width:600,
                    //labelAlign: 'top',
                    url:'/auditor/updateInformation',
                    buttonAlign:'center',
                    autoHeight:true,
                    fileUpload: true,
                    bodyStyle: 'padding:5px',
                    labelWidth:100,
                    waitMsgTarget: true,
                    frame: true,
                    reader:new Ext.data.JsonReader({
                    },[
                      {name:'id'},
                      {name:'login_id'},
                      {name:'name'},
                      {name:'mobile'},
                      {name:'phone'},
                      {name:'email'},
                      {name:'department_id'}
                    ]),
                    items:[{
                          layout:'column',
                          items:[{
                              columnWidth:.5,
                              layout:'form',
                              labelAlign: 'top',
                              items:[{
                                  xtype:'hidden',
                                  name:'id'
                              },{
                                  xtype:'textfield',
                                  fieldLabel: '我的编号',
                                  name: 'login_id',
                                  allowBlank:false,
                                  disabled:true,
                                  anchor:'90%'
                              },{
                                  xtype:'textfield',
                                  fieldLabel: '移动电话',
                                  name: 'mobile',
                                  allowBlank:false,
                                  anchor:'90%' 
                              },{
                                  xtype:'textfield',
                                  fieldLabel: 'Email',
                                  name: 'email',
                                  allowBlank:false,
                                  anchor:'90%'
                              }]
                          },{
                              columnWidth:.5,
                              layout:'form',
                              labelAlign: 'top',
                              items:[{
                                  xtype:'textfield',
                                  fieldLabel: '我的姓名',
                                  name:'name',
                                  allowBlank:false,
                                  anchor:'90%'
                              },{
                                  xtype:'textfield',
                                  fieldLabel: '固定电话',
                                  name: 'phone',
                                  allowBlank:false,
                                  anchor:'90%'
                              },{
                                  xtype:'combo',
                                  store: departmentDS,
                                  displayField:'name',
                                  hiddenName:'department_id',
                                  valueField:'id',
                                  typeAhead: true,
                                  allowBlank:false,
                                  disabled:true,
                                  minChars:1,
                                  anchor: '90%',
                                  mode: 'remote',
                                  fieldLabel:'所属部门',
                                  forceSelection: true,
                                  triggerAction: 'all',
                                  emptyText:'请选择所属部门.....',
                                  selectOnFocus:true
                              }]
                          }]
                     }],
                     buttons:[{
                        text:'确定',
                        handler: function(){
                            
                            // check form value
                            if (editAuditorForm.form.isValid()) {
                              editAuditorForm.form.submit({
                                method: 'post',
                                waitMsg: '正在保存个人信息...',
                                success: function(result, response){
                                  if (response.result.info == "success") {
                                    //添加成功后，隐藏窗口，并刷新Grid
                                    editAuditorWin.destroy();
                                  }
                                  else {
                                    Ext.MessageBox.alert('消息', response.result.info);
                                  }
                                },
                                failure: function(result, response){
                                  Ext.MessageBox.alert('提示', result.responseText);
                                }
                              });
                            }
                            else {
                              Ext.MessageBox.alert('错误提示', '请按要求填写必输选项.');
                            }
                          }
                    },{
                        text:'取消',
                        handler:function(){
                            editAuditorWin.destroy();
                        }
                    }]
                });
          editAuditorForm.form.load({
               url: '/auditor/edit?id=' + auditorId,
               success: function(form, action){
               },
               failure: function(form, action){
                  Ext.MessageBox.alert('提示信息', '信息加载失败');
               }
          });
          editAuditorForm.render('edit_auditor_form');
      })
    </script>
  </head>
  <body>
     <div id="edit_auditor_form"></div>
  </body>
</html>
